import random

class Puzzle8State():
    init_state_list = [1,2,3,4,5,6,7,8,0]
    def __init__(self, state = None, parent=None, move=None):
        if state is not None:
            self.cur_state_list = state[:]
        else:
            self.cur_state_list = None
        self.parent = parent
        self.move = move

    def random_generate(self):
        tmp = random.sample(self.init_state_list,9)
        self.cur_state_list = tmp[:];
        return tmp

    def reset(self):
        tmp = self.init_state_list[:]
        self.cur_state_list = tmp[:];
        return tmp

    def get_cur_list(self):
        if self.cur_state_list is None:
            return None
        tmp =  self.cur_state_list[:]
        return tmp

    def get_move(self):
        return self.move

    def get_parent(self):
        return self.parent

    def __eq__(self,other):
        return self.cur_state_list == other.cur_state_list